package 线程创建.Runnable接口;
//实现Runnable接口，重写run()方法，执行线程需要把实现Runnable接口的对象放入线程对像（Thread）中使用Thread对象的start()方法开启线程.
public class testThread1 {
    public static void main(String[] args) {
        //创建实现Runnable接口的方法
        Runnable1 runnable1 = new Runnable1();
        //创建线程对象,通过线程对象开启线程,代理
        Thread thread = new Thread(runnable1);
        //开启线程
        thread.start();

        for (int i = 0; i < 100; i++) {
            System.out.println("这是main()"+i);
        }
    }

}
//实现Runnable接口的类
class Runnable1 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("这是线程"+i);
        }
    }
}